package com.lv.suyiyong.hfrwork.ui

import android.graphics.Color
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.lv.common.base.BaseActivity
import com.lv.common.imp.OnPositionTListener
import com.lv.common.utils.ARoutUtils
import com.lv.common.utils.StatusBarUtil

import com.lv.service.bean.UserInfoTabBean
import com.lv.suyiyong.hfrwork.R
import com.lv.suyiyong.hfrwork.adapter.UserInfoTabAdapter
import com.lv.suyiyong.hfrwork.databinding.ActivityUserinfoCollectionDetailBinding

/**
 * 作者： ygx
 * 创建日期：2023/5/6 10:33 AM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 * -    _              _           _     _   ____  _             _ _
 * -   / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 * -  / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 * - / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 * -/_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 * <p>
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 * 描述：已收集个人信息清单
 */
@Route(path = ARoutUtils.UserinfoCollectionDetailsActivity)
class UserinfoCollectionDetailsActivity : BaseActivity<ActivityUserinfoCollectionDetailBinding>() {
    @Autowired(name = "type")
    @JvmField
    var mType: String? = null
    private var mAdapter: UserInfoTabAdapter? = null
    private var mInfoTabBeans = mutableListOf<UserInfoTabBean>()
    override fun getLayoutRes() = R.layout.activity_userinfo_collection_detail
    override fun initView() {
        super.initView()
        initStatusBar(this, true, true)
        ARouter.getInstance().inject(this)
        mBinding.apply {
            StatusBarUtil.setHeightAndPadding(this@UserinfoCollectionDetailsActivity, titleBar)
            titleBar.onClickBackIcon { finish() }
            titleBar.setTitle("已收集个人信息清单")
//            tvCode.setOnClickListener(this@UserinfoCollectionDetailsActivity)

        }
    }


    override fun initConfig() {
        super.initConfig()
        mInfoTabBeans.clear()
        val userInfoTabBean1 = UserInfoTabBean()
        val userInfoTabBean2 = UserInfoTabBean()
        val userInfoTabBean3 = UserInfoTabBean()
        val userInfoTabBean4 = UserInfoTabBean()
        val userInfoTabBean5 = UserInfoTabBean()


        if ("0" == mType) {
            userInfoTabBean1.name = ("手机号码")
            userInfoTabBean1.target = ("创建账号、登录帐户")
            userInfoTabBean1.scene = ("用户注册/绑定账号时；用户登录账号时")
            userInfoTabBean1.collect = ("已收集1条")
            userInfoTabBean1.content = ("去查看>")
            userInfoTabBean2.name = ("头像")
            userInfoTabBean2.target = ("在用户个人中心、个人主页、账号管理等界面展示")
            userInfoTabBean2.scene = ("用户上传图像时；基本资料展示时")
            userInfoTabBean2.collect = ("已收集0条")
            userInfoTabBean2.content = ("去查看>")
            userInfoTabBean3.name = ("账号名")
            userInfoTabBean3.target = ("创建账号、登录账号、账号安全")
            userInfoTabBean3.scene = ("用户注册、登录账号时；基本资料展示时")
            userInfoTabBean3.collect = ("已收集1条")
            userInfoTabBean3.content = ("去查看>")
            userInfoTabBean4.name = ("登录密码")
            userInfoTabBean4.target = ("创建账号、登录账号、账号安全")
            userInfoTabBean4.scene = ("用户注册、登录账号时；用户设置/修改/找回登录密码时")
            userInfoTabBean4.collect = ("已收集1条")
            userInfoTabBean4.content = ("去查看>")
            mInfoTabBeans.add(userInfoTabBean1)
            mInfoTabBeans.add(userInfoTabBean2)
            mInfoTabBeans.add(userInfoTabBean3)
            mInfoTabBeans.add(userInfoTabBean4)
        } else if ("1" == mType) {
            userInfoTabBean1.name = ("位置信息")
            userInfoTabBean1.target = ("基于位置信息向用户提供周边服务推荐等")
            userInfoTabBean1.scene = ("用户使用位置信息提供的服务时")
            userInfoTabBean1.collect = ("已收集0条")
            userInfoTabBean1.content = ("去查看>")
            userInfoTabBean2.name = ("搜索记录")
            userInfoTabBean2.target = ("搜索服务")
            userInfoTabBean2.scene = ("用户每次搜索时")
            userInfoTabBean2.collect = ("已收集0条")
            userInfoTabBean2.content = ("去查看>")
            userInfoTabBean3.name = ("订单记录")
            userInfoTabBean3.target = ("订单管理")
            userInfoTabBean3.scene = ("用户每次成功提交订单时")
            userInfoTabBean3.collect = ("已收集0条")
            userInfoTabBean3.content = ("去查看>")
            userInfoTabBean4.name = ("评论记录")
            userInfoTabBean4.target = ("评论互动")
            userInfoTabBean4.scene = ("用户每次成功发表评论时")
            userInfoTabBean4.collect = ("已收集0条")
            userInfoTabBean4.content = ("去查看>")
            userInfoTabBean5.name = ("剪切板")
            userInfoTabBean5.target = ("链接、口令等信息分享")
            userInfoTabBean5.scene = ("用户每次打开APP分享信息或接收信息分享时")
            userInfoTabBean5.collect = ("已收集0条")
            userInfoTabBean5.content = ("-")
            mInfoTabBeans.add(userInfoTabBean1)
            mInfoTabBeans.add(userInfoTabBean2)
            mInfoTabBeans.add(userInfoTabBean3)
            mInfoTabBeans.add(userInfoTabBean4)
            mInfoTabBeans.add(userInfoTabBean5)
        } else if ("2" == mType) {
            userInfoTabBean1.name = ("AdroidID")
            userInfoTabBean1.target = ("个性化内容及广告推荐；安全风控")
            userInfoTabBean1.scene = ("用户打开APP时；判断安全风控事件时")
            userInfoTabBean1.collect = ("已收集0条")
            userInfoTabBean1.content = ("-")
            userInfoTabBean2.name = ("MAC地址")
            userInfoTabBean2.target = ("个性化内容及广告推荐；安全风控")
            userInfoTabBean2.scene = ("用户打开APP时；判断安全风控事件时")
            userInfoTabBean2.collect = ("已收集0条")
            userInfoTabBean2.content = ("-")
            userInfoTabBean3.name = ("IMEI")
            userInfoTabBean3.target = ("个性化内容及广告推荐；安全风控")
            userInfoTabBean3.scene = ("用户打开APP时；判断安全风控事件时")
            userInfoTabBean3.collect = ("已收集0条")
            userInfoTabBean3.content = ("-")
            mInfoTabBeans.add(userInfoTabBean1)
            mInfoTabBeans.add(userInfoTabBean2)
            mInfoTabBeans.add(userInfoTabBean3)
        }

        val linearLayoutManager = LinearLayoutManager(this)
        linearLayoutManager.orientation = RecyclerView.VERTICAL
        mBinding.rvContent.setLayoutManager(linearLayoutManager)
        mAdapter = UserInfoTabAdapter(mInfoTabBeans)
        mBinding.rvContent.adapter = mAdapter
        val topHeader =
            View.inflate(this@UserinfoCollectionDetailsActivity, R.layout.user_info_tab_top, null)
        val footView =
            View.inflate(this@UserinfoCollectionDetailsActivity, R.layout.item_bottom, null)
        val tv_name = topHeader.findViewById<TextView>(R.id.tv_name)
        val tv_target = topHeader.findViewById<TextView>(R.id.tv_target)
        val tv_scene = topHeader.findViewById<TextView>(R.id.tv_scene)
        val tv_collect = topHeader.findViewById<TextView>(R.id.tv_collect)
        val tv_content = topHeader.findViewById<TextView>(R.id.tv_content)

        tv_name.paint.isFakeBoldText = true
        tv_target.paint.isFakeBoldText = true
        tv_scene.paint.isFakeBoldText = true
        tv_collect.paint.isFakeBoldText = true
        tv_content.paint.isFakeBoldText = true
        tv_name.setBackgroundColor(Color.parseColor("#fafafa"))
        tv_target.setBackgroundColor(Color.parseColor("#fafafa"))
        tv_scene.setBackgroundColor(Color.parseColor("#fafafa"))
        tv_collect.setBackgroundColor(Color.parseColor("#fafafa"))
        tv_content.setBackgroundColor(Color.parseColor("#fafafa"))
        mAdapter?.addHeaderView(topHeader)
        mAdapter?.addFooterView(footView)
    }


    override fun initData() {
        super.initData()
        mAdapter?.onViewClickListener = OnPositionTListener { position, data ->
//            if ("0" == mType) {
//                UiHelp.showPersonalInfoActivity(this@UserInfoCollectTabActivity)
//            } else if ("位置信息" == name) {
//                val dk = CommonDataKeeper(this@UserInfoCollectTabActivity, Constants.DK_LOCAL)
//                var currentCity: String = dk.get("dingCity", "武汉")
//                if (currentCity.endsWith("市")) {
//                    currentCity = currentCity.substring(0, currentCity.length - 1)
//                }
//                UiHelp.showAddressActivity(this@UserInfoCollectTabActivity, currentCity)
//            } else if ("搜索记录" == name) {
//                UiHelp.showSearchActivity(this@UserInfoCollectTabActivity, "", 0)
//            } else if ("订单记录" == name) {
//                UiHelp.showPhoneBuyRecodeActivity(this@UserInfoCollectTabActivity)
//            } else if ("评论记录" == name) {
//                UiHelp.showHuDongMessageActivity(this@UserInfoCollectTabActivity)
//            }
        }
    }


}